package com.geek.activemq;

import com.geek.activemq.jms.JmsProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.jms.annotation.EnableJms;

import java.util.HashMap;
import java.util.Map;

@SpringBootApplication
@EnableJms
public class ActiveMqApplication implements ApplicationRunner {

    public static void main(String[] args) {
        SpringApplication.run(ActiveMqApplication.class, args);
    }

    @Autowired
    private JmsProducer producer;

    @Override
    public void run(ApplicationArguments args) {
        String topic = "activeTest";
        Map<String, String> map = new HashMap<>(4);
        map.put("activeMq", "hello activeMq");
        producer.sendMessage(topic, map);
    }
}
